package com.IR.product.service;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.IR.shop.mapper.ProductMapper;
import com.IR.shop.po.Product;


/**
 * @author 单立鑫
 * @date 2018-09-06
 * */
@Service
public class AProductBIZ {
	
	@Resource
	private  ProductMapper promapper;
	
	/*删除商品*/
	public void deletePro(Long proid) {
		promapper.deleteByPrimaryKey(proid);
		
	}
	
	/*商品上架*/
	public void updateProUp(Long proid) {
		Product pro=promapper.selectByPrimaryKey(proid);
		pro.setIspro(1);
		promapper.updateByPrimaryKey(pro);
	}
	
	/*商品下架*/
	public void updateProDown(Long proid) {
		Product pro=promapper.selectByPrimaryKey(proid);
		pro.setIspro(0);
		promapper.updateByPrimaryKey(pro);
	}
	
	/*通过id修改商品*/
	public void updatePro(Product pro) {
		promapper.updateByPrimaryKey(pro);
	}
	
	/*添加商品以及商品的详细信息*/
	public void saveProAndDetail(Product pro) {
		//通过日期生成id
		SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMddHHmmssSSS");
		String ss=format1.format(new Date());
		pro.setIspro(1);
		pro.setProid(new Long(ss));
		promapper.insert(pro);
	}

	
}
